import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.concurrent.PriorityBlockingQueue;


public class priorityqueue {
	
	public static void main(String[] args) {
		Comparator<String> comp=new strinhlengthcomp();
		PriorityQueue<String> q= new PriorityQueue<String>();
		q.add("sac");
		q.add("sachin");
		q.add("sa");
		System.out.println(q);
		while(q.size()!=0){
			System.out.println("\n"+q.remove());
		}
		
		
	}

}
class strinhlengthcomp implements Comparator<String>{
	public int compare(String str1,String str2){
		if(str1.length()<str2.length()){
			return -1;
		}
		if(str1.length()>str2.length()){
			return 1;
		}
		return 0;
	}
}